package com.jia.together.controller.front;

import com.jia.together.entity.Course;
import com.jia.together.service.CourseService;
import com.jia.together.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
@RequestMapping("/front/course")
//@CrossOrigin
public class CourseFrontController {

    @Autowired
    private CourseService courseService;

    @GetMapping("/getDetails/{id}")
    public R getDetails(@PathVariable String id){
        Course course = courseService.selectDetails(id);
        return R.ok().data("course",course);
    }
    @GetMapping("/getListByTypeId")
    public R getListByTypeId(@RequestParam String courseTypeId,@RequestParam Long pageNum,@RequestParam Long pageSize){
        Map<String,Object> map = courseService.selectByTypeId(courseTypeId,pageNum,pageSize);
        return R.ok().data(map);
    }
    @GetMapping("/clickCourse")
    public R clickCourse(@RequestParam String courseId,@RequestParam(required = false) String memberId){
        courseService.click(courseId,memberId);
        return R.ok();
    }

}
